home *** CD-ROM | disk | FTP | other *** search
/ Delphi 2.0 - Programmer's Utilities Power Pack / Delphi 2.0 Programmer's Utilities Power Pack.iso / e_to_l / jpgdll / main.pas < prev    next >
Pascal/Delphi Source File  |  1996-09-15  |  4KB  |  149 lines

  1. unit Main;
  2.  
  3.  (*
  4.  Shareware. Send Check or Moneyorder of $49 to:
  5.  Jan Dekkers, 11956 Riverside Dr. 206
  6.  N. Hollywood CA 91607.
  7.  
  8.  (c) 1995 by:
  9.  
  10.  Kevin Adams (CIS) 74742,1444
  11.  Jan Dekkers (CIS) 72130,353
  12.  
  13.  This DLL will display a reminder after the 5th picture is displayed.
  14.  
  15.  Registering this software will motivate us to finish the remaining image
  16.  library which will include GIF and PCX support. Registered users will
  17.  receive a VCL interface derived of TImage free of charge in 1 about month.
  18.  
  19.  Happy coding.
  20.  
  21.  Kevin Adams              Jan Dekkers
  22.  
  23.  
  24.  Make sure that your program can access the DLL
  25.  
  26.  By the way: This delphi example is not invalidating the TImage
  27.  correctly so that the seccond picture displayed still has garbage
  28.  of the first picture in it. This has nothing to do with the DLL
  29.  but with the way this Delphi sample is put together.
  30.  
  31. *)
  32.  
  33.  
  34. interface
  35.  
  36. uses
  37.   SysUtils, WinTypes, WinProcs, Messages, Classes, Graphics, Controls,
  38.   Forms, Dialogs, ExtCtrls, JpgImage, Menus, StdCtrls;
  39.  
  40. var
  41.     res, {resolution}
  42.     scale, {size}
  43.     dither : Integer; {dither method}
  44.     Bitmap : TBitmap;
  45.  
  46. type
  47.   TForm1 = class(TForm)
  48.     ScrollBox1: TScrollBox;
  49.     Image1: TImage;
  50.     MainMenu1: TMainMenu;
  51.     OpenDialog1: TOpenDialog;
  52.     File1: TMenuItem;
  53.     Open1: TMenuItem;
  54.     GroupBox1: TGroupBox;
  55.     Radio4: TRadioButton;
  56.     Radio8: TRadioButton;
  57.     Radio24: TRadioButton;
  58.     GroupBox2: TGroupBox;
  59.     DithRadio24: TRadioButton;
  60.     DithOnepassRadio: TRadioButton;
  61.     DithOnepassOrderedRadio: TRadioButton;
  62.     DithTwopassRadio: TRadioButton;
  63.     DithTwopassFSRadio: TRadioButton;
  64.     procedure FormCreate(Sender: TObject);
  65.     procedure FormClose(Sender: TObject; var Action: TCloseAction);
  66.     procedure Open1Click(Sender: TObject);
  67.     procedure DithRadio24Click(Sender: TObject);
  68.   private
  69.     { Private declarations }
  70.     procedure OpenJpeg(fname : String);
  71.     Function GetDithering : Integer;
  72.     Function GetResolution : Integer;
  73.   public
  74.     { Public declarations }
  75.   end;
  76.  
  77. var
  78.   Form1: TForm1;
  79.  
  80. implementation
  81.  
  82. {$R *.DFM}
  83.  
  84. procedure TForm1.FormCreate(Sender: TObject);
  85. begin
  86.     {}
  87. end;
  88.  
  89. procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
  90. begin
  91.   Action := caFree;
  92. end;
  93.  
  94. procedure TForm1.Open1Click(Sender: TObject);
  95. begin
  96.   If OpenDialog1.Execute then
  97.     OpenJpeg(OpenDialog1.FileName);
  98. end;
  99.  
  100. procedure TForm1.OpenJpeg(fname : String);
  101. begin
  102.   res := GetResolution;
  103. { res: 8 - 8 bit,      24 - 24 bit,     4 - 4 bit
  104.        8 = 256 colors, 24 = true color, 4 = 16 colors}
  105.  
  106.   dither := GetDithering;
  107. { dither: 0 = 24 bit bitmap
  108.            1 = One pass no dithering
  109.            2 = one pass ordered dithering
  110.            3 = two pass no dithering
  111.            4 = two pass FS dithering}
  112.  
  113.   scale := 1;
  114. { scale: 1 = 1/1, 2 = 1/2, 4 = 1/4, 8 = 1/8 size of image}
  115.  
  116.   Bitmap := TBitmap.Create;
  117.   jpgfile(fname, res, scale, dither, Bitmap);
  118.   Image1.Picture.Bitmap := Bitmap;
  119.   Bitmap.Free;
  120. end;
  121.  
  122.  
  123. Function TForm1.GetDithering : Integer;
  124.  var r : integer;
  125. begin
  126.     if DithRadio24.Checked then r:=0 else
  127.     if DithOnepassRadio.Checked then r:=1 else
  128.     if DithOnepassOrderedRadio.Checked then r:=2 else
  129.     if DithTwopassRadio.Checked then r:=3 else
  130.     if DithTwopassFSRadio.Checked then r:=4;
  131.     GetDithering:=r;
  132. end;
  133.  
  134. Function TForm1.GetResolution : Integer;
  135.  var r : integer;
  136. begin
  137.     if Radio4.Checked then r:=4 else
  138.     if Radio8.Checked then r:=8 else
  139.     if Radio24.Checked then r:=24;
  140.     GetResolution:=r;
  141. end;
  142.  
  143. procedure TForm1.DithRadio24Click(Sender: TObject);
  144. begin
  145.     if DithRadio24.Checked then Radio24.Checked:=True;
  146. end;
  147.  
  148. end.
  149.